﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Domain.Ranges
{
    /// <summary>
    /// Specifications for the construction of a range.
    /// </summary>
    [TestClass]
    public class WhenConstructingRanges
    {
        /// <summary>
        /// Should set the begin and end..
        /// </summary>
        [TestMethod]
        public void ShouldSetPropertiesCorrectly()
        {
            DateTime begin = new DateTime(1980, 04, 30);
            DateTime end = begin.AddDays(10);

            Range<DateTime> dateTimeRange = new Range<DateTime>(begin, end);
            Assert.AreEqual(begin, dateTimeRange.Begin);
            Assert.AreEqual(end, dateTimeRange.End);
        }

        /// <summary>
        /// Should throw when end is before end.
        /// </summary>
        [ExpectedException(typeof (ArgumentOutOfRangeException))]
        public void ShouldThrowWhenBeginIsAfterEnd()
        {
            DateTime begin = new DateTime(1980, 04, 30);
            DateTime end = begin.AddDays(-10);

            new Range<DateTime>(begin, end);
        }
    }
}